package webank.d20210910.t2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

/**
 * 解方程：x^3 + y^4 + z^5 = k
 * @author habitplus
 * @since 2021-09-10 20:59
 */
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());
        long k;
        while (t-- > 0) {
            k = Long.parseLong(br.readLine());
            boolean ans = solve(k);
            System.out.println(ans ? "YES" : "NO");
        }
    }

    private static boolean solve(long k) {
        if (k < 0) return false;

        int i = 1;
        long p = 1L;
        Set<Long> set3 = new HashSet<>();
        Set<Long> set4 = new HashSet<>();
        while (p < k - 1) {
            set3.add(p);
            i++;
            p = (long) Math.pow(i, 3);
        }

        p = 1L;
        i = 1;
        while (p < k - 1) {
            set4.add(p);
            i++;
            p = (long) Math.pow(i, 4);
        }

        long z = 1;
        i = 1;
        while (z < k - 1) {
            for (long x : set4) {
                if (k > z + x && set3.contains(k - z - x)) {
                    return true;
                }
            }
            i++;
            z = (long) Math.pow(i, 5);
        }
//        for (int z = 1; z < 1000; z++) {
//            zr = (long) Math.pow(z, 5);
//            if (zr > k - 2) break;
//            for (int y = 1; y < 1000; y++) {
//                yr = (long) Math.pow(y, 4);
//                if (yr + zr > k - 1) break;
//
//                t = k - zr - yr;
//                if (set.contains(t)) return true;
//            }
//        }
        return false;
    }
}
